package problem;

import java.util.List;

/**
 * <p>
 * 二叉树的前序遍历
 * </p>
 * 给你二叉树的根节点 root ，返回它节点值的 前序 遍历。
 *
 * @author fangXK
 * @date 2021/2/1/001 15:57
 */
public class S_144 {
    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    // 1、递归
    public List<Integer> preorderTraversal(TreeNode root) {
        return null;
    }

    public void preOrder(TreeNode root, List<Integer> res) {
        if(root==null){
            return;
        }
        res.add(root.val);
        preOrder(root.left,res);
        preOrder(root.right,res);
    }
}
